<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>
<?=$page_title?>
</title>
<base href="<?=base_url()?>" />
<link href="css/clientpublic.css" rel="stylesheet" type="text/css">
<link href="css/esui.css" rel="stylesheet" type="text/css">
<link href="css/initaccount.css" rel="stylesheet" type="text/css">
<link href="css/guo.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript"
	src="js/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<script type="text/javascript"
	src="js/fancybox/jquery.easing-1.3.pack.js"></script>
<script type="text/javascript"
	src="js/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
<link rel="stylesheet" type="text/css"
	href="js/fancybox/jquery.fancybox-1.3.4.css" />
<link rel="stylesheet" type="text/css" href="css/jia.css" />
<!---提示--->
<script language='javascript' src='js/suggest.js'></script>
<link href="js/suggest.css" rel="stylesheet" type="text/css">
<!---共享弹出框---->
<link href="styles/core.css" type="text/css" rel="stylesheet" />
<script src="scripts/popup_layer_s.js" type="text/javascript"
	language="javascript"></script>
<script type="text/javascript">
	$(document).ready(function() {
		jQuery.ajaxSetup ({cache:false}); /*让ajax不调用浏览的缓存*/
		$(".various1").fancybox({
			'titleShow'     : false,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic',
			'easingIn'      : 'easeOutBack',
			'easingOut'     : 'easeInBack',
			'hideOnOverlayClick' : false,
			'onComplete'	: function() {
				var suggest = new GoogleSuggest("myform", "customer_name", 0,'');
			}
		});

		$(".g_title_sub").click(function(){
            var name=$.trim($("#name").val());
            if(name == ""){
              alert("请输入联系人名称后查询");
              $("#name").focus();
            }else{
				location.href="<?=base_url()?>index.php/contacter/check/"+name+"";
              }
		})

		$("#con_county_button").click(function(){
			var city_id = $("#con_city").val();
			var county_id = $("#con_county").val();
			if(city_id == 'zero'){
				alert('请选择市局');
			}else{
				location.href="<?= base_url()?>index.php/contacter/con_city_customers/"+city_id+"/"+county_id+"";
			}
		})
	});
</script>
</head>
<body>
	<div id="Holder">
		<div id="MainPage">
			<!---------头部------------->
			<?php include('top.php')?>
			<div id="Subnav">
				<ul>
					<li class="active show"></li>
				</ul>
			</div>
			<!---------中间部分------------->
			<div id="MainBody">
				<div class="g_title">
					<div class="g_earch">
						<input type="text" class="g_title_text" value="联系人名称"
							onClick="this.value=''" id="name"><input type="button" value=" "
							class="g_title_sub">
					</div>
					<div class="gj_earch">
						<select id="con_city">
							<option value="zero">请选择市区</option>
                            <?php foreach ($parent_customers as $parent_item):?>
                            	<option
								value="<?= $parent_item->customer_id?>"
								<?php if($con_city_id == $parent_item->customer_id):?>
								selected='selected' <?php endif;?>>
                            		<?= $parent_item->customer_name?>
                            	</option>
                            <?php endforeach;?>
                        </select>
                        <select class="gj_earch_2" id="con_county">
							<option value="0">请选县区</option>
                        	<?php foreach ($county_customers as $item_customer):?>
                        		<option value=<?= $item_customer->customer_id?> <?php if($con_county_id == $item_customer->customer_id):?> selected='selected' <?php endif;?>>
                        			<?= $item_customer->customer_name?>
                        		</option>
                        	<?php endforeach;?>
                        </select>
                        <input type="button" value="" id="con_county_button" class="gj_earch_but">
					</div>
					<div class="add_customer">
						<div class="add_customer_bg2"><?=anchor('contacter/show_contacter_add/',' ','class="various1"','id="find"') ?></div>
					</div>


					<script type="text/javascript">
						$(function(){
							var $con_city = $("#con_city");
							var $con_county = $("#con_county");
							$con_city.change( function() {
								var con_city = $con_city.val();
								if(con_city == 'zero'){
									$con_county.html('');
									$con_county.append('<option value="0">请选县市区</option>');
								}else{
									$.ajax({
										type: "POST",
										dataType: "text",
										url: "<?= base_url()?>index.php/contacter/get_contacer_county",
										data: "parent_id="+con_city,
										success: function(data) {
											  $con_county.html('');
											  data=$.parseJSON(data);
											  var array='<option value="0">请选县市区</option>';
											  $.each(data,function(index,nw){
											  		array+="<option value="+nw.customer_id+">"+nw.customer_name+"</option>";
				                	 			});
												$con_county.append(array);
										}
									});
								}
							 })
						})
					</script>

				</div>
				<table id="ContentTable" class="data-box">
					<thead>
						<tr class="border-in">
							<th><div>ID</div></th>
							<th><div>对应客户</div></th>
							<th><div>所属部门</div></th>
							<th><div>姓名</div></th>
							<th><div>工作电话</div></th>
							<th><div>移动电话</div></th>
							<th><div>职务</div></th>
							<th><div>编辑</div></th>
						</tr>
					</thead>
					<tbody id="tbody_g_tit">
					<?php foreach ($contacter as $contacter_item): ?>
					<tr class="data-box-row">
							<td><?=$contacter_item->id ?></td>
							<td><?=$contacter_item->customer_name ?></td>
							<td><?=$contacter_item->department ?></td>
							<td><?=$contacter_item->name?>
							 <?php if($contacter_item->sex):?>
							   <img src="images/man.png" height="13" width='13' align="absmiddle" alt='男' title="男"/>
							 <?php endif;?>
							 <?php if(!$contacter_item->sex):?>
							   <img src="images/women.png" height="13" width='13' align="absmiddle" alt='女' title="女"/>
							 <?php endif;?>
							</td>
							<td><?=$contacter_item->work_tel ?></td>
							<td><?=$contacter_item->mobile_phone ?></td>
							<?php
						$fenlei = '';

						if ($contacter_item->last_contact_time == null || $contacter_item->last_contact_time == '' || $contacter_item->last_contact_time == '0000-00-00 00:00:00') {
							$lastcontacttime = '';
						} else {
							$datatime = strtotime ( $contacter_item->last_contact_time );
							$lastcontacttime = date ( "Y-m-d", $datatime );
						}
						?>
							<td><?=$contacter_item->post ?></td>
							<td><a
								href="<?=base_url()?>index.php/contacter/find/<?=$contacter_item->id ?>"
								class="various1 g_see" id="find" title="">查看</a>&nbsp;&nbsp; <a
								href="<?=base_url()?>index.php/contacter/edit/<?=$contacter_item->id ?>"
								class="various1 g_edit" id="find" title="">编辑</a>&nbsp;&nbsp;
								<?php if(($contacter_item->customer_user_id == $this->session->userdata('id')) || ($this->session->userdata('role') == '经理')):?>
								<span class="g_dele" id="delete<?=$contacter_item->id ?>">删除</span>
								<?php endif;?>
								 <input type="hidden" id="contacter_id<?=$contacter_item->id ?>"
								value="<?=$contacter_item->id ?>" /> <script
									type="text/javascript">
                                     $(function(){
                                    	 $("#delete<?=$contacter_item->id ?>").click(function(){
                                  			if (window.confirm("您确定要删除吗？")) {
                                  				var id=$("#contacter_id<?=$contacter_item->id ?>").val();
                                  				location.href="<?=base_url()?>index.php/contacter/delete/"+id+"";
                                  			} else {
                                  			}
                                  		})
                                     })
								</script></td>
						</tr>
		          <?php endforeach; ?>
		        </tbody>
				</table>
				<div id="PageControl">
					<div class="page-control">
						<div class="border-in">
							<span class="perpage"> <span class="perpage-text">
							<?php if($pag_links || $check_pag_links){?>
								<?echo ($offset) ? ($offset+1):1;?> - <?=$current_total?> 条（共<?=$total?>条）
							<?php }?>
							</span>
							</span>
							<p>
								<?php

								if ($pag_links) {
									echo $pag_links;
								}
								?>
							</p>
						</div>
					</div>
				</div>
			</div>
			<!---------结尾------------->
			<?php include('footer.php')?>
		</div>
	</div>
	<input type="hidden" id="baseurl" value="<?=base_url()?>" />
	<input type="hidden" id="error_info" value="<?= $error_info?>" />
	<script type="text/javascript">
		$(function(){
			var error_info = $('#error_info').val();
			if(error_info){
				alert(error_info);
			}

			$("table").delegate('tr',"hover", function(){
				$(this).toggleClass("hover");
			});
			//$("table").delegate('tr',"mouseout", function(){
				//$(this).removeClass("hover");
			//});
		})
	</script>
</body>
</html>